//
//  ALPPlayListTableViewCell.m
//  AlpFM
//
//  Created by KING on 16/2/27.
//  Copyright © 2016年 Alp. All rights reserved.
//

#import "ALPPlayListTableViewCell.h"


@interface ALPPlayListTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *playTimes;
@property (nonatomic, strong) UILabel *longTime;
@property (nonatomic, strong) UILabel *favNum;

@end

@implementation ALPPlayListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews{
    //标题
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.053*SCREEN_WIDTH, 0.013*SCREEN_WIDTH, 0.933*SCREEN_WIDTH, 0.053*SCREEN_WIDTH)];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.font = [UIFont systemFontOfSize:0.037*SCREEN_WIDTH];
    self.titleLabel.text = @"你不知道的西游记";
//    self.titleLabel.backgroundColor = CLEAR;
    
    //播放次数
    self.playTimes = [[UILabel alloc] initWithFrame:CGRectMake(0.106*SCREEN_WIDTH, 0.075*SCREEN_WIDTH, 0.133*SCREEN_WIDTH, 0.053*SCREEN_WIDTH)];
    [self.contentView addSubview:self.playTimes];
    self.playTimes.text = @"12765";
    self.playTimes.font = [UIFont systemFontOfSize:0.037*SCREEN_WIDTH];
//    self.playTimes.backgroundColor = CLEAR;
    
    //时长
    self.longTime = [[UILabel alloc] initWithFrame:CGRectMake(0.32*SCREEN_WIDTH, 0.075*SCREEN_WIDTH, 0.133*SCREEN_WIDTH, 0.053*SCREEN_WIDTH)];
    [self.contentView addSubview:self.longTime];
    self.longTime.text = @"18:23";
    self.longTime.font = [UIFont systemFontOfSize:0.037*SCREEN_WIDTH];
//    self.longTime.backgroundColor = CLEAR;
    
    //关注
    self.favNum = [[UILabel alloc] initWithFrame:CGRectMake(0.533*SCREEN_WIDTH, 0.075*SCREEN_WIDTH, 0.133*SCREEN_WIDTH, 0.053*SCREEN_WIDTH)];
    [self.contentView addSubview:self.favNum];
    self.favNum.text = @"257";
    self.favNum.font = [UIFont systemFontOfSize:0.037*SCREEN_WIDTH];
//    self.favNum.backgroundColor = CLEAR;
    
    //播放次数
    UIImageView *timesView = [[UIImageView alloc] initWithFrame:CGRectMake(0.04*SCREEN_WIDTH, 0.061*SCREEN_WIDTH, 0.08*SCREEN_WIDTH, 0.08*SCREEN_WIDTH)];
    [self.contentView addSubview:timesView];
    timesView.image = [UIImage imageNamed:@"setting_loglistenpos@2x.png"];
    
    //时长
    UIImageView *longTimeView = [[UIImageView alloc] initWithFrame:CGRectMake(0.27*SCREEN_WIDTH, 0.082*SCREEN_WIDTH, 0.04*SCREEN_WIDTH, 0.04*SCREEN_WIDTH)];
    [self.contentView addSubview:longTimeView];
    longTimeView.image = [UIImage imageNamed:@"me_setting_playhis@2x.png"];
    
    //关注
    UIImageView *favNumView = [[UIImageView alloc] initWithFrame:CGRectMake(0.48*SCREEN_WIDTH, 0.083*SCREEN_WIDTH, 0.04*SCREEN_WIDTH, 0.04*SCREEN_WIDTH)];
    [self.contentView addSubview:favNumView];
    favNumView.image = [UIImage imageNamed:@"me_setting_comment@2x.png"];
    
    //下面小条
    UIImageView *botView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0.155*SCREEN_WIDTH, SCREEN_WIDTH, 2)];
    [self.contentView addSubview:botView];
    botView.image = [UIImage imageNamed:@"bot"];
    
    //轻扫手势
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(Action:)];
    //设置轻扫方向
    swipe.direction = UISwipeGestureRecognizerDirectionRight;
    //添加
    [self.contentView addGestureRecognizer:swipe];
    
}

#pragma mark - 轻扫返回上一页
- (void)Action:(UISwipeGestureRecognizer *)btn{
    
    [self.MyDelegate popLastPage];
    //        NSLog(@"向右滑动手势执行");
}

#pragma mark - 赋值
- (void)setModel:(ALPSingleModel *)model{
    _model = model;
    
    self.titleLabel.text = _model.title;
    
    NSInteger wan = _model.playtimes.intValue / 10000;
    NSInteger qian = _model.playtimes.intValue % 10000;
    self.playTimes.text = [NSString stringWithFormat:@"%ld.%02ld万", (long)wan, (long)qian / 100];
    
    NSInteger min = _model.duration.intValue / 60;
    NSInteger sec = _model.duration.intValue % 60;
    
    self.longTime.text = [NSString stringWithFormat:@"%02ld:%02ld", (long)min, (long)sec];
    self.favNum.text = [NSString stringWithFormat:@"%@",_model.comments];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
